feat(io): add reader implementation for BufRead#196
feat(io): add reader implementation for BufRead#196kskalski wants to merge 1 commit intoanza-xyz:masterfrom
Conversation
75e8eec to
b4dd766
Compare
|
The complexity and state management required for this implementation is a strong indication to me that we should actually deprecate With those removed, implementation can simply become: wincode/wincode/src/io/std_read_direct.rs Lines 1 to 27 in 00c64f1 There is a benchmark in this branch you can run: https://github.com/anza-xyz/wincode/blob/af1904c5d8f83c6c8fa44aa45fba09dae0ffd21f/wincode/benches/reader.rs The simple implementation without On x86, The simple solution, relative to the solution in this PR is:
The simple solution, relative to bincode is:
This isn't to say that we couldn't further optimize the solution proposed here to be closer to the performance of bincode or the solution without We only have two cases in My feeling is that we should merge the context system and deprecate
wincode/wincode/benches/reader.rs Lines 349 to 358 in af1904c And we'll only need to add one context implementation for |
Introduces
BufReadAdapter<R>inwincode::io::std_readmodule, a low-overhead wrapper over anystd::io::BufReadsource (e.g.BufReader<R>) implementingwincode::io::Reader.Mix of consuming and scoped borrowing operations supported by checking consume state on each operation and using one of:
peek_arrayandtake_scopedreturn a subslice directly with no allocation,copy_into_sliceusesreaddirectly into thedstbufferfill_bufis requested, bytes are assembled into anaux_buf: Vec<u8>. Subsequent operations can re-serve or extend from this buffer, but switch back to using internal reader once the bytes inaux_bufare consumed.